package #(package).service;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import #(package).model.#(className);

import java.util.List;

public class #(className)Service {
    public static #(className)Service #(smallClassName)Service = new #(className)Service();
    private #(className) dao = new #(className)().dao();

    public void add(#(className) #(smallClassName)){
        #(smallClassName).save();
    }

    public void update(#(className) #(smallClassName)){
        #(smallClassName).update();
    }

    public void delete(int id){
        dao.deleteById(id);
    }

    public #(className) findById(int id){
         return dao.findFirst("select * from t_#(smallClassName) where id=?",id);
    }

    public Page<#(className)> paginate(int pageNumber, int pageCount){
        return dao.paginate(pageNumber,pageCount,"select * " ,"from t_#(smallClassName)");
    }
}
